<?php
    Yii::app()->clientScript->registerScriptFile('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js');
    Yii::app()->clientScript->registerCssFile('css/jquery-ui-1.8.14.custom.css');
    Yii::app()->clientScript->registerCssFile('css/stock/grid/fip-style.css');
    Yii::app()->clientScript->registerCssFile('css/stock/importFromWeb.css');
?>

<!--Date picker-->
<script>
    $(function(){
        $( "#from" ).datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd/mm/yy',
            changeMonth: true,
            changeYear: true,
            yearRange: '-10:+0',
            maxDate: 0
        });

        $( "#to" ).datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd/mm/yy',
            changeMonth: true,
            changeYear: true,
            yearRange: '-10:+0',
            maxDate: 0
        });
    });
</script>

<!--`Stock` box updated due to changes on `House` box-->
<script type="text/javascript">
    $(document).ready(function()
    {
        $(".house").change(function()
        {
            var id=$(this).val();
            var dataString = 'id='+ id;

            $.ajax
            ({
                type: "POST",
                url: "index.php?r=ajax/getStockID",
                data: dataString,
                cache: false,
                success: function(html)
                {
                    $(".stock_id").html(html);
                }
            });

        });
    });
</script> <!--js-->

<div class="form">
    <form>
        <div id="webChoices">
            Supported Web <br/>
            <input id="web1" value="FPT" type="radio" name="webpage" checked ><b> FPT</b>
        </div><!--webChoices-->

        <div id="FPTInputs">
            House
            <select id="house" name="house" class="house">
                <option value="1">All</option>
                <option value="1">HOSE</option>
                <option value="2">HNX</option>
                <option value="4">UPCOM</option>
            </select>
            &nbsp;&nbsp;
            Stock
            <select id="stock_id" name="stock_id" class="stock_id">
                <option value="">All</option>
            </select>
            <br/>
            &nbsp;
            From
            <?php echo CHtml::textfield(
                'from'
            ); ?>
            &nbsp;&nbsp;
            to
            <?php echo CHtml::textfield(
                'to'
            ); ?>
        </div><!--FPTInputs-->

        <div style="clear:both">&nbsp;</div>

        <div id="submission">
        <?php
        echo CHtml::ajaxSubmitButton(
            'Preview',
            array('ajax/PreviewImportFromWeb'),
            array(
                'class' => 'submitButton',
                'update' => '#result',

                'error' => 'js:function(){
                    alert(\'Error\');
                }',

                'beforeSend' => 'js:function(){
                    var status = document.getElementById(\'status\');
                    status.innerHTML = "Generating...";
                }',

                'complete' => 'js:function(){
                    var status = document.getElementById(\'status\');
                    status.innerHTML = "Done";
                }'
            )
        );
        echo '&nbsp';
        echo CHtml::ajaxSubmitButton(
            'Import',
            array('ajax/startImportFromWeb'),
            array(
                'class' => 'submitButton',
                'update' => '#result',

                'error' => 'js:function(){
                    alert(\'Error\');
                }',

                'beforeSend' => 'js:function(){
                    var status = document.getElementById(\'status\');
                    status.innerHTML = "Importing...";
                }',

                'complete' => 'js:function(){
                    var status = document.getElementById(\'status\');
                    status.innerHTML = "Done";
                }'
            )
        );
        ?>
        </div><!--submission-->

        <div id="status">&nbsp;</div>

        <div id="result">&nbsp;</div>
    </form>
</div><!-- form -->